package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.AddGwcBean;
import com.lwj.liwanjia.impl.AddGwcView;
import com.lwj.liwanjia.model.AddGwcModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/9/30.
 */

public class AddGwcPresenter {
    private AddGwcView addGwcView;
    private AddGwcModel addGwcModel;

    public AddGwcPresenter(AddGwcView addGwcView) {
        this.addGwcView = addGwcView;
        addGwcModel = new AddGwcModel();
    }

    public void addGouWuChe(String token, String commendityCode, String commendityType, double price) {
        if (addGwcView != null) {
            addGwcModel.addGouWuChe(token, commendityCode, commendityType, price, new Subscriber<AddGwcBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    addGwcView.showError((Exception) e);
                }

                @Override
                public void onNext(AddGwcBean addGwcBean) {
                    addGwcView.addGouWuChe(addGwcBean);
                }
            });
        }
    }
}
